#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define endl '\n'
#define int long long
#define pii pair<int, int>
using namespace std;

// 已知
int n;
// 未知
int cnt = 0, p = 2;

signed main()
{
    cin >> n;
    while (p <= n)
    {
        int t = n / p;
        int b = sqrt(t);
        while (b * b > t) b--; // 小心精度原因导致b * b > t的情况
        cnt += (b + 1) / 2; // 只记录奇数，偶数会和a结合变成更高次方
        p *= 2;
    }
    cout << cnt;
    return 0;
}